/***************************************************************************

Copyright (c) Microsoft Corporation. All rights reserved.
This code is licensed under the Visual Studio SDK license terms.
THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.

***************************************************************************/

using System;
using System.Collections.Generic;

namespace Microsoft.WowAddonStudio.Lua.Parser
{
    public class ListErrorHandler : IErrorHandler
    {
        private readonly List<Error> errors = new List<Error>();

        private int errorCount;
        private int warningCount;

        public bool HasErrors
        {
            get { return errorCount > 0; }
        }

        public bool HasWarnings
        {
            get { return warningCount > 0; }
        }

        public int ErrorCount
        {
            get { return errorCount; }
        }

        public int WarningCount
        {
            get { return warningCount; }
        }

        public void AddError(string message, int line, int column, int length, bool isWarning)
        {
            if (message == null)
                throw new ArgumentNullException("message");

            errors.Add(new Error(message, line, column, length, isWarning));

            if (isWarning)
                warningCount++;
            else
                errorCount++;
        }
    }
}